package com.andy.beef.ui.main.api

import com.andy.module.BASE_BREED
import com.andy.module.BASE_WAGY
import com.andy.beef.ui.main.bean.group.BreedEnumGroupBean
import com.andy.beef.ui.main.bean.EnterInfoBean
import com.andy.beef.ui.main.bean.FarmCattleBean
import com.andy.beef.ui.main.bean.FenceBean
import com.andy.beef.ui.main.bean.group.WagyEnumGroupBean
import com.andy.module.network.*
import retrofit2.http.FieldMap
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST
import retrofit2.http.Url

/**
 * @creator:LuoFan
 * @date:2022/6/8
 * @description:
 */

//双重校验锁式-单例 封装NetApiService 方便直接快速调用简单的接口
val cattleService: CattleApiService by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
    RetrofitClient.getService(CattleApiService::class.java, SimpleApiService.SERVER_URL)
}

interface CattleApiService : SimpleApiService {

    companion object {

        //场内牛只列表
        const val URL_FARM_CATTLE_LIST = BASE_BREED + "mobile/cattle/list"

        //新增牛只
        const val URL_CATTLE_ADD = BASE_BREED + "mobile/cattle/add"

        //新增牛只
        const val URL_CATTLE_EDIT = BASE_BREED + "mobile/cattle/edit"

        //围栏列表
        const val URL_FENCE_LIST = BASE_BREED + "mobile/cattleFence/list"

        //breed模块下的enum集合
        const val URL_BREED_ENUM = BASE_BREED + "config/common/get-all-enum-list"

        //breed模块下的config集合
        const val URL_BREED_CONFIG = BASE_BREED + "config/common/get-config-list"

        //大肥牛模块下的enum集合
        const val URL_WAGY_ENUM = BASE_WAGY + "config/common/get-all-enum-list"

        //大肥牛模块下的config集合
        const val URL_WAGY_CONFIG = BASE_WAGY + "config/common/get-config-list"
    }

    /**
     * 获取入场信息列表
     */
    @FormUrlEncoded
    @POST
    suspend fun getEnterInfoList(
        @Url url: String,
        @FieldMap params: HashMap<String, Any>
    ): ApiResponse<ApiPagerResponse<EnterInfoBean>>

    /**
     * 获取场内牛只信息
     */
    @FormUrlEncoded
    @POST
    suspend fun getFarmCattleList(
        @Url url: String,
        @FieldMap params: HashMap<String, Any>
    ): ApiResponse<ApiPagerResponse<FarmCattleBean>>

    /**
     * 获取围栏列表
     */
    @FormUrlEncoded
    @POST
    suspend fun getFenceList(
        @Url url: String?,
        @FieldMap params: HashMap<String, Any>
    ): ApiResponse<ApiPagerResponse<FenceBean>>

    /**
     *
     */
    @FormUrlEncoded
    @POST
    suspend fun getBreedGroup(
        @Url url: String?,
        @FieldMap params: HashMap<String, Any>
    ): ApiResponse<BreedEnumGroupBean>

    /**
     *
     */
    @FormUrlEncoded
    @POST
    suspend fun getWagyGroup(
        @Url url: String?,
        @FieldMap params: HashMap<String, Any>
    ): ApiResponse<WagyEnumGroupBean>
}